package
{
	import app.mvc.AppFacade;
	import app.mvc.view.AppMainView;
	import app.mvc.view.components.panels.AlertPanel;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import globals.Global;
	
	/**
	 * 应用程序入口
	 * @author XiLing
	 */
	[SWF(backgroundColor="#999999", frameRate="24", width="1000", height="600")]
	public class UIEditor extends Sprite
	{
		private var appMainView:AppMainView;
		
		public function UIEditor()
		{
			addEventListener(Event.ADDED_TO_STAGE,onAdded);
		}
		
		private function onAdded(evt:Event):void
		{
			 removeEventListener(Event.ADDED_TO_STAGE,onAdded);
			 init();
		}
		
		internal function init():void
		{
			onResize(null);
			
			appMainView = new AppMainView();
			var facade:AppFacade = AppFacade.getInstance();
			facade.startup({app:this,appView:appMainView});
			
			mouseEnabled = false;
			tabEnabled = false;
			
			stage.addEventListener(Event.RESIZE,onResize,false,100);
			
			stage.nativeWindow.addEventListener(Event.CLOSING,onClosing);
		}
		
		internal function onClosing(evt:Event):void
		{
//			evt.preventDefault();
//			AlertPanel.show("确定退出么",function():void{
//				stage.nativeWindow.close();
//			});
		}
		
		internal function onResize(evt:Event):void
		{
			Global.stage = stage;
			Global.stageW = stage.stageWidth;
			Global.stageH = stage.stageHeight;
			
		}
	}
}